<template>
  <div class="app-container">
    <template>
      <div class="right-detail">
        <div class="cbox">
          <el-form class="form" :model="queryParam" ref="queryParam" :rules="rules" :inline="true" size="mini">
            <!-- <el-row :gutter="12" class="row">
            <el-col :span="4">-->
            <el-form-item size="mini" label="标的编号:" prop="bidCode">
              <el-input clearable v-model="queryParam.bidCode" size="mini" style="width:180px"></el-input>
            </el-form-item>
            <!-- </el-col> -->
            <!-- <el-col :span="4"> -->
            <el-form-item size="mini" label="标的名称:" prop="bidName">
              <el-input clearable v-model="queryParam.bidName" size="mini" style="width: 180px"></el-input>
            </el-form-item>
            <!-- </el-col> -->
            <!-- <el-col :span="2"> -->
            <el-form-item label-width="10px">
              <el-button @click="searchType" type="primary">查询</el-button>
            </el-form-item>
            <!-- </el-col> -->
            <!-- </el-row> -->
          </el-form>
        </div>
        <split-pane split="horizontal" v-on:resize="resize" :default-percent="55" :max-percent="80">
          <!-- 上半部分 -->
          <template slot="paneL">
            <div class="top-type" ref="topType" style="top:49%">
              <!-- <div class="btn-area" ref="btnArea">
                <el-button plain size="mini" type="primary" @click="auditButton">查看竞价信息</el-button>
              </div>-->

              <!-- 状态（E-启用 N-未启用 D-停用） -->
              <el-table
                :data="TypeList"
                :height="typeHeight"
                highlight-current-row
                class="demand"
                @row-click="getCurrentTypeRow"
                border
                :header-cell-style="{ textAlign: 'center' }"
                :cell-style="{}"
              >
                <el-table-column size="mini" show-overflow-tooltip type="index" label="序号" align="center" width="60">
                  <template slot-scope="scope">
                    <span>{{ (Pagination.currentPage - 1) * Pagination.pageSize + scope.$index + 1 }}</span>
                  </template>
                </el-table-column>
                <el-table-column align="center" label="标的状态" prop="bidStatus" width="105" show-overflow-tooltip></el-table-column>
                <el-table-column size="mini" show-overflow-tooltip prop="bidCode" width="120" align="center" label="标的编号"></el-table-column>
                <el-table-column size="mini" show-overflow-tooltip prop="bidType" width="80" align="center" label="标的类型"></el-table-column>
                <el-table-column size="mini" show-overflow-tooltip prop="bidName" width="220" align="center" label="标的名称"></el-table-column>
                <el-table-column align="center" label="是否与平台合作" prop="bidPlatformTogether" width="150" show-overflow-tooltip>
                  <template slot-scope="scope">
                    <span v-if="scope.row.bidPlatformTogether == 'N'">否</span>
                    <span v-if="scope.row.bidPlatformTogether == 'Y'">是</span>
                  </template>
                </el-table-column>
                <el-table-column size="mini" show-overflow-tooltip prop="bidAmount" align="center" label="运输总量（吨）" width="120"></el-table-column>
                <el-table-column size="mini" show-overflow-tooltip prop="bidQuotations" width="80" align="center" label="竞价方式"></el-table-column>
                <el-table-column size="mini" show-overflow-tooltip prop="bidOffer" align="center" label="单价竞价范围（元/吨）" width="150"></el-table-column>
                <el-table-column show-overflow-tooltip align="center" width="120" prop="dptName" label="标的来源"></el-table-column>
                <el-table-column size="mini" show-overflow-tooltip header-align="left" align="left" prop="bidRemark" label="备注"></el-table-column>
              </el-table>
              <div>
                <el-pagination
                  class="pagination"
                  small
                  background
                  ref="pagination"
                  @size-change="handleSizeChange"
                  @current-change="handleCurrentChange"
                  :current-page="Pagination.currentPage"
                  :page-sizes="Pagination.pageSizeList"
                  :page-size="Pagination.pageSize"
                  :layout="Pagination.layout"
                  :total="Pagination.total"
                ></el-pagination>
              </div>
            </div>
          </template>

          <!-- 下半部分 -->
          <template slot="paneR">
            <div class="codeNumberCode" style="background-color: #fff;">需求信息</div>
            <div class="bottom-code" ref="bottomCode" style="background-color: #fff;">
              <div class="btn-area" ref="detlArea">
                <buttonName @clickEvent="clickEventDom"></buttonName>
                <!-- <el-button plain size="mini" type="primary" @click="queryBiddingButton">查看竞价结果</el-button> -->
                <!-- <el-button plain size="mini" type="primary" v-if="isAuth('review')" @click="review">评审</el-button>
                <el-button plain size="mini" type="primary" v-if="isAuth('reviewDel')" @click="reviewDel">取消评审</el-button>
                <el-button plain size="mini" type="primary" v-if="isAuth('annouce')" @click="annouce">中标公告发布</el-button>-->
              </div>
              <el-table
                :height="detlHeight"
                :data="currentCodeList"
                highlight-current-row
                @row-click="getCurrentCodeRow"
                border
                @selection-change="rowSelectionChange"
                :header-cell-style="{
                  textAlign: 'center'
                }"
                :cell-style="{}"
              >
                <el-table-column type="selection" align="center" width="55"></el-table-column>
                <el-table-column show-overflow-tooltip type="index" :index="indexMethodDet" label="序号" width="60" align="center"></el-table-column>
                <el-table-column align="center" label="评审状态" prop="reviewStatus" width="80" show-overflow-tooltip>
                  <template slot-scope="scope">
                    <span v-if="scope.row.reviewStatus == 'N'">未通过</span>
                    <span v-if="scope.row.reviewStatus == 'Y'">已通过</span>
                  </template>
                </el-table-column>
                <el-table-column size="mini" show-overflow-tooltip width="120" align="left" prop="demandCode" label="需求编号"></el-table-column>
                <!-- <el-table-column show-overflow-tooltip align="center" prop="brand" label="货物品牌"></el-table-column>
                <el-table-column show-overflow-tooltip align="center" prop="dailyOutput" label="规格"></el-table-column>
                <el-table-column size="mini" show-overflow-tooltip prop="product" align="center" label="产品大类"></el-table-column>
                <el-table-column size="mini" show-overflow-tooltip prop="kind" align="center" label="品种"> </el-table-column>-->
                <el-table-column show-overflow-tooltip align="center" prop="transportType" label="运输类型"></el-table-column>
                <el-table-column size="mini" show-overflow-tooltip prop="transportMode" align="center" label="运输方式"></el-table-column>
                <el-table-column show-overflow-tooltip align="center" prop="transportQuantity" label="运输数量(吨)"></el-table-column>
                <el-table-column show-overflow-tooltip align="center" prop="dptName" label="需求来源"></el-table-column>
                <el-table-column size="mini" show-overflow-tooltip prop="remark" align="center" label="备注"></el-table-column>
                <el-table-column align="center" label="操作" width="200">
                  <template slot-scope="scope">
                    <el-button size="mini" type="primary" plain @click="queryDemand(scope.row)">详情</el-button>
                    <el-button size="mini" type="primary" plain @click="rankInfo(scope.row)">查看竞价排名</el-button>
                  </template>
                </el-table-column>
              </el-table>
              <!-- <div>
                <el-pagination class="pagination" small background
                  @size-change="handleSizeChangeA"
                  @current-change="handleCurrentChangeA"
                  :current-page="currentPage"
                  :page-sizes="[30, 60, 90, 120]"
                  :page-size="30"
                  layout="sizes, prev, pager, next, jumper, total"
                  :total="pageTotal">
                </el-pagination>
              </div>-->
            </div>
            <!-- <div class="codeNumberCode" style="background-color: #fff;">
              供应商信息
            </div>
            <div
              class="bottom-code"
              ref="bottomCode"
              style="background-color: #fff;"
            >
              <div class="btn-area" ref="detlArea">
                <el-button plain size="mini" type="primary" v-if="isAuth('review')" @click="review">评审</el-button>
                <el-button plain size="mini" type="primary" v-if="isAuth('reviewDel')" @click="reviewDel">取消评审</el-button>
              </div>
              <el-table :height="detlHeight" :data="currentCodeList" highlight-current-row @row-click="getCurrentCodeRow" border
                   @selection-change="rowSelectionChange"
                  :header-cell-style="{
                    textAlign: 'center'
                  }" :cell-style="{}" >
                <el-table-column type="selection"  align="center" width="55"></el-table-column>
                <el-table-column show-overflow-tooltip type="index" :index="indexMethodDet" label="序号" width="60" align="center"></el-table-column>
                <el-table-column type="index" show-overflow-tooltip width="60"  label="名次" align="center"></el-table-column>
                <el-table-column align="center" label="评审状态" prop="reviewStatus" width="80" show-overflow-tooltip>
                <template slot-scope="scope">
                    <span v-if="scope.row.reviewStatus =='N'">未通过</span>
                    <span v-if="scope.row.reviewStatus =='Y'">已通过</span>
                  </template>
                </el-table-column>
                <el-table-column size="mini" show-overflow-tooltip   width="380" align="center" prop="usrName" label="供应商"></el-table-column>
                <el-table-column size="mini" show-overflow-tooltip prop="biddingPrice"  align="center" label="竞价金额"></el-table-column>
                <el-table-column size="mini" show-overflow-tooltip prop="biddingTime" align="center" label="竞价时间"></el-table-column>
              </el-table>
            </div>-->
          </template>
        </split-pane>
      </div>
    </template>

    <!-- 供应商评审 -->
    <!-- <el-dialog
      title="企业信息"
      :visible.sync="openDialog"
      v-if="openDialog"
      v-el-drag-dialog
      :before-close="close"
      :destroy-on-close="true"
      :close-on-click-modal="false">
      <el-form
        :model="dialogForm"
        size="mini"
        :rules="dialogRule"
        ref="dialogForm"
        label-width="auto"
      >
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item prop="fltName" label="企业名称：">
              <el-input
                v-model="dialogForm.fltName"
                style="width:95%"
                clearable
                readonly="ture"
                maxlength="32"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item prop="fltAddress" label="企业地址：">
              <el-input
                v-model="dialogForm.fltAddress"
                style="width:95%"
                clearable
                readonly="ture"
                maxlength="32"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item prop="fltPhone" label="企业电话：">
              <el-input
                v-model="dialogForm.fltPhone"
                style="width:95%"
                clearable
                readonly="ture"
                maxlength="32"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item prop="fltCode" label="企业代码：">
              <el-input
                v-model="dialogForm.fltCode"
                style="width:95%"
                clearable
                readonly="ture"
                maxlength="32"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item prop="fltLegalPersonName" label="法人身份证姓名：">
              <el-input
                v-model="dialogForm.fltLegalPersonName"
                style="width:95%"
                clearable
                readonly="ture"
                maxlength="32"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item prop="fltLegalPersonId" label="法人身份证号：">
              <el-input
                v-model="dialogForm.fltLegalPersonId"
                style="width:95%"
                clearable
                readonly="ture"
                maxlength="32"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item prop="fltLegalPersonPhone" label="法人联系电话：">
              <el-input
                v-model="dialogForm.fltLegalPersonPhone"
                style="width:95%"
                clearable
                readonly="ture"
                maxlength="32"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item prop="fltBusinessLicenseNo" label="营业执照注册号：">
              <el-input
                v-model="dialogForm.fltBusinessLicenseNo"
                style="width:95%"
                clearable
                readonly="ture"
                maxlength="32"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item prop="fltTotal" label="入驻得分：">
              <el-input
                v-model="dialogForm.fltTotal"
                style="width:95%"
                clearable
                readonly="ture"
                maxlength="32"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="openDialog = false" size="mini">关闭</el-button>
        <el-button type="primary" @click="reviewTure" size="mini">评审通过</el-button>
      </div>
    </el-dialog>-->

    <el-dialog
      width="40%"
      :close-on-click-modal="false"
      :close-on-press-escape="false"
      v-el-drag-dialog
      title="线路详情"
      :visible.sync="tranDialogInfoDialogVisible"
      v-if="tranDialogInfoDialogVisible"
      :before-close="handleTypeDialogClose"
    >
      <el-table
        :data="tranDialogInfoList"
        :height="detlHeight"
        highlight-current-row
        border
        :header-cell-style="{
          textAlign: 'center'
        }"
        :cell-style="{}"
      >
        <el-table-column type="index" width="60" align="center" label="序号"></el-table-column>
        <el-table-column show-overflow-tooltip align="center" label="起始地" prop="site"></el-table-column>
        <el-table-column show-overflow-tooltip align="center" label="目的地" prop="destination"></el-table-column>
      </el-table>
      <span slot="footer" class="dialog-footer">
        <el-button
          size="mini"
          type="primary"
          @click="
            tranDialogInfoDialogVisible = false
            tranDialogInfoList = []
          "
          >关闭</el-button
        >
      </span>
    </el-dialog>

    <!-- 竞价结果 -->
    <el-dialog
      title="竞价结果"
      :visible.sync="openDialog"
      v-if="openDialog"
      v-el-drag-dialog
      :before-close="close"
      :destroy-on-close="true"
      :close-on-click-modal="false"
    >
      <el-table
        :height="detlHeight"
        :data="biddingResultList"
        highlight-current-row
        border
        :header-cell-style="{
          textAlign: 'center'
        }"
        :cell-style="{}"
      >
        <el-table-column show-overflow-tooltip type="index" :index="indexMethodDet" label="序号" width="60" align="center"></el-table-column>
        <el-table-column prop="rank" show-overflow-tooltip width="60" label="名次" align="center"></el-table-column>
        <el-table-column size="mini" show-overflow-tooltip width="380" align="center" prop="usrName" label="供应商"></el-table-column>
        <el-table-column size="mini" show-overflow-tooltip prop="biddingPrice" align="center" label="竞价金额"></el-table-column>
        <el-table-column size="mini" show-overflow-tooltip prop="biddingTime" align="center" label="竞价时间"></el-table-column>
      </el-table>
      <div slot="footer" class="dialog-footer">
        <el-button @click="openDialog = false" size="mini">关闭</el-button>
        <el-button type="primary" v-if="rankQuerry" @click="reviewTure" size="mini">评审通过</el-button>
      </div>
    </el-dialog>

    <!-- 公告发布 -->
    <el-dialog width="50%" :close-on-click-modal="false" :close-on-press-escape="false" v-el-drag-dialog title="公告发布" :visible.sync="annoucetDialog">
      <el-form label-position="right" :model="annouceData" ref="annouceData" :rules="annouceDataRules" label-width="auto" size="mini">
        <el-row>
          <el-col :span="19">
            <el-form-item prop="bidTitle" label="标题：">
              <el-input v-model="annouceData.bidTitle" placeholder="请输入标题" clearable filterable></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="2">
            <el-button plain type="primary" size="mini" style="margin-left: 20px;" @click="addAnnex">添加附件</el-button>
          </el-col>
          <el-col :span="22">
            <el-form-item prop="bidContent" label="内容：">
              <Editor v-model="annouceData.bidContent" />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer" style="margin-top: 20px;">
        <el-button size="mini" @click="annoucetDialog = false">关闭</el-button>
        <el-button size="mini" type="primary" @click="annouceTrue">确认发布</el-button>
      </div>
    </el-dialog>

    <!-- 需求详情 -->
    <el-dialog
      width="1100px"
      top="5vh"
      v-dialogDrag
      v-el-drag-dialog
      :close-on-click-modal="false"
      :close-on-press-escape="false"
      v-if="showDialog"
      :visible.sync="showDialog"
      :title="operate"
    >
      <el-form ref="basicForm" :model="currentFltInfo" label-width="15rem" inline="true" size="mini">
        <el-row>
          <el-form-item label="需求编号:" prop="demandCode">
            <el-input readonly="ture" v-model="currentFltInfo.demandCode" style="width:50"></el-input>
          </el-form-item>
          <el-form-item label="货物品牌:" prop="goodBrand">
            <el-input readonly="ture" v-model="currentFltInfo.brand"></el-input>
          </el-form-item>
          <el-form-item label="规格:" prop="dailyOutput">
            <el-input readonly="ture" v-model="currentFltInfo.dailyOutput"></el-input>
          </el-form-item>
        </el-row>
        <el-row>
          <el-form-item label="产品大类:" prop="projuctBig">
            <el-input readonly="ture" v-model="currentFltInfo.product"></el-input>
          </el-form-item>
          <el-form-item label="品种:" prop="kind">
            <el-input readonly="ture" v-model="currentFltInfo.kind"></el-input>
          </el-form-item>
          <el-form-item label="结算方式:" prop="settlementWay">
            <el-input readonly="ture" v-model="currentFltInfo.settlementWay"></el-input>
          </el-form-item>
          <el-form-item label="货物编码:" prop="goodCode" v-if="false">
            <el-input readonly="ture" v-model="currentFltInfo.goodCode"></el-input>
          </el-form-item>
        </el-row>
        <el-row>
          <el-form-item label="运输类型:" prop="transportType">
            <el-input readonly="ture" v-model="currentFltInfo.transportType"></el-input>
          </el-form-item>
          <el-form-item label="运输方式:" prop="transportMode">
            <el-input readonly="ture" v-model="currentFltInfo.transportMode"></el-input>
          </el-form-item>
          <el-form-item label="运输数量(吨):" prop="transportQuantity">
            <el-input readonly="ture" v-model="currentFltInfo.transportQuantity"></el-input>
          </el-form-item>
        </el-row>
        <el-row>
          <el-form-item label="履约保证金（元）:" prop="performanceBond">
            <el-input readonly="ture" v-model="currentFltInfo.performanceBond"></el-input>
          </el-form-item>
          <el-form-item label="要求开始时间:" prop="requiredStartTime">
            <el-input readonly="ture" v-model="currentFltInfo.requiredStartTime"></el-input>
          </el-form-item>
          <el-form-item label="要求完成天数:" prop="requiredEndDay">
            <el-input readonly="ture" v-model="currentFltInfo.requiredEndDay"></el-input>
          </el-form-item>
        </el-row>

        <el-row>
          <el-col :span="22">
            <el-form-item label="备注:" prop="remark">
              <el-input readonly="ture" type="textarea" v-model="currentFltInfo.remark" style="width: 500px"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <!-- 弹窗下方线路信息模块 -->

      <el-table
        :data="tranDialogInfoList"
        :height="detlHeight"
        highlight-current-row
        border
        :header-cell-style="{
          textAlign: 'center'
        }"
        :cell-style="{}"
      >
        <el-table-column type="index" width="60" align="center" label="序号"></el-table-column>
        <el-table-column show-overflow-tooltip align="center" label="起始地" prop="site"></el-table-column>
        <el-table-column show-overflow-tooltip align="center" label="目的地" prop="destination"></el-table-column>
      </el-table>
      <span slot="footer" class="dialog-footer">
        <el-button
          size="mini"
          type="primary"
          @click="
            showDialog = false
            tranDialogInfoList = []
            currentFltInfo = []
          "
          >关闭</el-button
        >
      </span>
    </el-dialog>

    <!--文件上传-->
    <el-dialog
      width="30%"
      :close-on-click-modal="false"
      :close-on-press-escape="false"
      v-el-drag-dialog
      :title="annexDialog.title"
      :visible.sync="annexDialog.show"
    >
      <el-row align="middle">
        <el-col align="middle">
          <el-upload
            class="upload-demo"
            drag
            ref="annexUpload"
            :action="annexDialog.uploadUrl"
            multiple
            :auto-upload="false"
            :file-list="annexDialog.fileList"
            :data="annexDialog.data"
            :on-error="fileUploadFileCallBack"
            name="files"
            :headers="annexDialog.headers"
          >
            <i class="el-icon-upload"></i>
            <div class="el-upload__text">将文件拖到此处，或点击<em>添加文件</em></div>
            <div class="el-upload__tip" slot="tip">文件大小不能超过10m</div>
          </el-upload>
        </el-col>
      </el-row>
      <span slot="footer" class="dialog-footer">
        <el-button
          @click="
            annexDialog.show = false
            annexDialog.fileList = []
          "
          >取 消</el-button
        >
        <el-button type="primary" @click="doUploadFile">确 定</el-button>
      </span>
    </el-dialog>

    <!-- 竞价结果推荐 -->
    <el-dialog
      title="竞价结果推荐"
      :visible.sync="openDialog2"
      v-if="openDialog2"
      v-el-drag-dialog
      :before-close="close"
      :destroy-on-close="true"
      :close-on-click-modal="false"
    >
      <el-table
        :height="detlHeight"
        :data="biddingResultList2"
        highlight-current-row
        border
        :header-cell-style="{
          textAlign: 'center'
        }"
        :cell-style="{}"
      >
        <el-table-column
          show-overflow-tooltip
          type="index"
          :index="indexMethodDet"
          label="序号"
          width="60"
          align="center"
        ></el-table-column>
        <el-table-column prop="rank" show-overflow-tooltip width="60" label="名次" align="center"></el-table-column>
        <el-table-column
          size="mini"
          show-overflow-tooltip
          width="380"
          align="center"
          prop="usrName"
          label="供应商"
        ></el-table-column>
        <el-table-column
          size="mini"
          show-overflow-tooltip
          prop="biddingPrice"
          align="center"
          label="竞价金额"
        ></el-table-column>
        <el-table-column
          size="mini"
          show-overflow-tooltip
          prop="biddingTime"
          align="center"
          label="竞价时间"
        ></el-table-column>
      </el-table>
      <div slot="footer" class="dialog-footer">
        <el-button @click=";(openDialog2 = false), (this.currentCode = [])" size="mini">关闭</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  addAnnouncement,
  auditBiddingMethod,
  queryBiddingInfoList,
  queryBiddingList,
  queryDemandLine,
  querytSignUpSugar,
  quotaBiddingMethod,
  reviewBiddingMethod
} from '@/request/api'
import resizeMixin from '@/mixins/resize'
import isAuth from '@/mixins/buttonAuth'
import paginationMixin from '@/mixins/pagination'
import Editor from '@/components/Editor'
import scrollChange from '@/utils/onscroll.js'
import buttonName from '@/components/buttonName/button-name.vue'
import store from '@/store'

export default {
  components: {
    Editor,
    buttonName
  },
  mixins: [resizeMixin, paginationMixin, isAuth],
  data() {
    var RVNAME = (rule, value, callback) => {
      // 获得字符串实际长度，中文2，英文1
      var realLength = 0,
        len = value.length,
        charCode = -1
      for (var i = 0; i < len; i++) {
        charCode = value.charCodeAt(i)
        if (charCode >= 0 && charCode <= 128) realLength += 1
        else realLength += 2
      }
      if (realLength > 32) {
        return callback(new Error('最多为32位'))
        // this.companyName = cutstr(this.companyName, 60);
      } else {
        return callback()
      }
    }
    var RVREMARK = (rule, value, callback) => {
      // 获得字符串实际长度，中文2，英文1
      var realLength = 0,
        len = value.length,
        charCode = -1
      for (var i = 0; i < len; i++) {
        charCode = value.charCodeAt(i)
        if (charCode >= 0 && charCode <= 128) realLength += 1
        else realLength += 2
      }
      if (realLength > 128) {
        return callback(new Error('最多为128位'))
        // this.companyName = cutstr(this.companyName, 60);
      } else {
        return callback()
      }
    }
    return {
      annexDialog: {
        show: false,
        title: '添加附件',
        uploadUrl: (process.env.NODE_ENV === 'development' ? '/proxy' : '') + '/FTKJWLHYPT/bidding/uploadFile',
        fileList: [],
        data: {
          id: undefined
        },
        headers: {
          Token: store.state.user.Session_Token
        }
      },
      queryParam: {
        bidCode: '', // 标的编号
        bidAuditstatus: '', // 标的审核状态
        bidName: '' //标的名称
      },
      diaTableData: [], // 弹出框需求信息数据
      statusList: [{ code: 'N', name: '未审核' }, { code: 'Y', name: '已审核' }],
      currentPage: 1,
      pageSize: 30,
      pageTotal: 0,

      rankQuerry: true, //插看竞价排名时隐藏按钮

      selNoApproveArray: [], //未评审的信息
      selApproveArray: [], //已评审的信息

      showDialog: false, //需求详情 Dialog
      operate: '',
      currentFltInfo: {},

      tranDialogInfoList: [],
      tranDialogInfoDialogVisible: false, //线路详情Dialog

      annoucetDialog: false, //发布公告 Dialog
      annouceData: {
        bidTitle: '',
        bidContent: ''
      }, //发布公告数据

      currentRow: '',
      codeentRow: '',
      typeHeight: -1,
      detlHeight: -1,
      CodeRCTUUID: false,
      CodeRVDOMAIN: false,
      checkedY: true,
      checkedN: false,
      flt: {
        rvDomain: '',
        rvName: ''
      },
      copyDomain: '',
      copyName: '',
      rleTypes: [],
      TypeMap: {
        updateType: 'baseCode.editClassify',
        createType: 'baseCode.addClassify'
      },
      CodeMap: {
        updateCode: 'baseCode.editCode',
        createCode: 'baseCode.addCode'
      },
      TypeDialogStatus: '',
      CodeDialogStatus: '',
      currentNode: {},
      currentType: {},
      TypeList: [],
      currentCodeList: [],
      currentCode: {},
      RefTypeDialogVisible: false, // 审核 Dialog
      RefCodeDialogVisible: false, // 基础代码 Dialog
      openDialog: false, //评审 Dialog
      openDialog2: false, //竞价结果推荐 Dialog
      biddingResultList: {}, //竞价结果推荐数据
      biddingResultList2: {}, //竞价结果推荐数据
      dialogForm: {},
      dialogText: {
        title: '',
        show: false,
        button: {
          t: '',
          f: ''
        },
        qeuryButtonShow: false,
        paginationShow: false
      },
      // 代码分类
      RefTypeData: {}, // 代码分类 dialog内的form([A-Z]|\d)[0-9a-zA-Z]
      rules: {
        RV_DOMAIN: [
          { min: 1, max: 4, message: '至多输入4 个字符', trigger: 'change' },
          {
            pattern: /^([^\u4e00-\u9fa5])+$/,
            message: '禁止输入中文',
            trigger: 'change'
          }
        ],
        RV_NAME: [
          { validator: RVNAME, trigger: 'change' },
          {
            pattern: /^([0-9a-zA-Z\u4e00-\u9fa5])+$/,
            message: '只能输入中文字母数字',
            trigger: 'change'
          }
        ]
      },
      RefTypeDataRules: {
        rvDomain: [
          // { validator: RVDOMAIN, trigger: 'change' },
          { min: 1, max: 4, message: '至多输入4个字符', trigger: 'change' },
          { required: true, message: '请填写类型编号', trigger: 'blur' }
          // {
          //   pattern: /^([^\u4e00-\u9fa5])+$/,
          //   message: '禁止输入中文',
          //   trigger: 'change'
          // }
        ],
        rvName: [
          { required: true, message: '请填写类型名称', trigger: 'blur' },
          { validator: RVNAME, trigger: 'change' },
          {
            pattern: /^([0-9a-zA-Z\u4e00-\u9fa5])+$/,
            message: '只能输入中文字母数字',
            trigger: 'change'
          }
        ],
        rvIsvalid: [{ required: true, message: '请选择有效标志', trigger: 'blur' }],
        rvRemark: [{ validator: RVREMARK, trigger: 'change' }]
      },

      annouceDataRules: {
        bidTitle: [{ required: true, message: '请输入标题', trigger: 'blur' }],
        bidContent: [{ required: true, message: '请输入内容', trigger: 'blur' }]
      },

      // 基础代码
      RefCodeData: {}, // 代码分类 dialog内的form
      RefCodeDataRules: {
        rvDomain: [{ required: true, message: '请选择代码类型', trigger: 'change' }],
        rvLowValue: [
          { min: 1, max: 4, message: '至多输入4个字符', trigger: 'change' },
          {
            pattern: /^([^\u4e00-\u9fa5])+$/,
            message: '禁止输入中文',
            trigger: 'change'
          },
          { required: true, message: '请填写代码编号', trigger: 'blur' }
        ],
        rvCmeaning: [
          { required: true, message: '请填写代码名称', trigger: 'blur' },
          { validator: RVNAME, trigger: 'change' }
          // {
          //   pattern: /^([0-9a-zA-Z\u4e00-\u9fa5])+$/,
          //   message: '只能输入中文字母数字',
          //   trigger: 'change'
          // }
        ],
        rvIsvalid: [{ required: true, message: '请选择有效标志', trigger: 'blur' }]
      }
    }
  },
  created() {
    this.resize = () => {
      this.typeHeight = this.$refs.topType.offsetHeight - 40
      // 70
      this.detlHeight = this.$refs.bottomCode.offsetHeight - 100
      // 130
    }
  },
  mounted() {
    let demandWrapper = document.querySelector('.demand .el-table__body-wrapper') // 新增滚动条监听事件
    scrollChange(demandWrapper)
  },
  beforeMount() {
    this.refreshList()
  },
  computed: {
    grandson() {
      var dataList = []
      var number
      var arr = this.$route.path.split('/')
      number = arr.length - 1
      dataList = this.$store.state.user.permList
      for (var i = 0; i < dataList.length; i++) {
        for (var f = 0; f < dataList[i].Children.length; f++) {
          if (dataList[i].Children[f].MDL_CODE == arr[number]) {
            return dataList[i].Children[f].Grandson
          }
        }
      }
      return []
    },
    disableType() {
      return this.TypeDialogStatus === 'updateType'
    }
  },
  methods: {
    //调取父组件方法
    clickEventDom(item) {
      if (item.mdlCode === 'review') {
        this.review()
      } else if (item.mdlCode === 'reviewDel') {
        this.reviewDel()
      } else if (item.mdlCode === 'annouce') {
        this.annouce()
      } else if (item.mdlCode === 'queryBiddingButton') {
        this.queryBiddingButton()
      }
    },

    dialogBeforeClose(done) {
      this.$confirm('确认关闭?')
        .then(() => {
          done()
        })
        .catch(() => {})
    },

    checkCode() {
      this.flt.RV_DOMAIN = this.flt.RV_DOMAIN.replace(/[^a-zA-Z]/g, '')
    },
    typecheck() {
      this.RefTypeData.RV_DOMAIN = this.RefTypeData.RV_DOMAIN.replace(/[^a-zA-Z]/g, '')
    },
    codecheck() {
      this.RefCodeData.RV_DOMAIN = this.RefCodeData.RV_DOMAIN.replace(/[^a-zA-Z]/g, '')
    },
    uppercase(key) {
      this.$refs.typePagination.lastEmittedPage = 1
      this.$refs.codePagination.lastEmittedPage = 1
      this.flt[key] = this.flt[key].toUpperCase()
    },
    // typeuppercase(key) {
    //   this.RefTypeData[key] = this.RefTypeData[key].toUpperCase()
    // },
    codeuppercase(key) {
      this.RefCodeData[key] = this.RefCodeData[key].toUpperCase()
    },
    getFltType() {
      addCodeTableXL({}).then(res => {
        if (res.success === '1') {
          this.rleTypes = res.data
        }
      })
    },
    searchType() {
      this.$refs.queryParam.validate(valid => {
        if (valid) {
          this.Pagination.currentPage = 1
          this.getList(this.Pagination.currentPage, this.Pagination.pageSize, this.updatePaginationTotal)
        }
      })
    },
    //获取列表
    getList(currentPage, pageSize, updateTotal) {
      this.currentCodeList = []
      this.RefTypeData = {}
      this.selNoApproveArray = []
      this.selApproveArray = []
      this.currentCode = {}
      this.RefCodeData = {}
      queryBiddingList({
        bidCode: this.queryParam.bidCode,
        bidName: this.queryParam.bidName,
        bidAuditstatus: 'Y',
        bidBiddingstatus: 'Y',
        bidPlatformTogether: 'Y', //只查询可评审的信息（平台查看与平台合作的）
        biddingEnd: 'Y', //只查询竞价结束的信息
        PageIndexs: this.Pagination.currentPage.toString(),
        PageSizes: this.Pagination.pageSize.toString()
      }).then(response => {
        this.TypeList = response.data
        updateTotal(Number(response.total))
      })
    },

    // 审核
    auditButton() {
      if (Object.keys(this.RefTypeData).length == 0) {
        this.$alert('请选择需要审核的信息！', '提示', {
          confirmButtonText: '确定'
        })
        return
      }

      if (this.RefTypeData.bidAuditstatus === 'Y') {
        this.$alert('请选择未审核的信息！', '提示', {
          confirmButtonText: '确定'
        })
        return
      }
      this.TypeDialogStatus = 'createType'
      this.RefTypeDialogVisible = true
    },
    // 取消审核
    delAuditButton() {
      if (Object.keys(this.RefTypeData).length == 0) {
        this.$alert('请选择需要取消审核的信息！', '提示', {
          confirmButtonText: '确定'
        })
        return
      }

      if (this.RefTypeData.bidAuditstatus === 'N') {
        this.$alert('请选择已审核的信息！', '提示', {
          confirmButtonText: '确定'
        })
        return
      }
      this.$confirm('您确定要取消审核该信息吗？', '提示', {
        confirmButtonText: '确定'
      }).then(() => {
        auditBiddingMethod({ bidId: this.currentType.bidId, bidAuditstatus: 'N' }).then(res => {
          if (res.success === '1') {
            this.$message({
              type: 'success',
              message: '取消审核成功'
            })
            this.RefTypeDialogVisible = false
            this.RefTypeData = {}
            this.refreshList()
          }
        })
      })
    },

    // 确认审核
    auditTrue() {
      this.$confirm('您确定要审核该信息吗？', '提示', {
        confirmButtonText: '确定'
      }).then(() => {
        auditBiddingMethod({ bidId: this.RefTypeData.bidId, bidAuditstatus: 'Y' }).then(res => {
          if (res.success === '1') {
            this.$message({
              type: 'success',
              message: '审核成功'
            })
            this.RefTypeDialogVisible = false
            this.RefTypeData = {}
            this.refreshList()
          }
        })
      })
    },

    //评审
    review() {
      if (this.selNoApproveArray.length < 1) {
        if (Object.keys(this.currentCode).length == 0) {
          this.$alert('请选择需要评审的信息！', '提示', {
            confirmButtonText: '确定'
          })
          return
        }
        this.RefCodeData = Object.assign({}, this.currentCode)
        if (this.RefCodeData.reviewStatus == 'Y') {
          this.$alert('请选择未通过评审的信息！', '提示', {
            confirmButtonText: '确定'
          })
          return
        }
        queryBiddingInfoList({
          bidId: this.RefTypeData.bidId,
          sugarId: this.RefCodeData.sugarId,
          biddingEnd: 'Y', //查询前三名推荐结果
          biddingStatus: 'Y' //已参与竞价的供应商
        }).then(res => {
          if (res.success == 1) {
            this.rankQuerry = true
            this.openDialog = true
            this.biddingResultList = res.data
          }
        })
      } else {
        if (this.selNoApproveArray.length == 0) {
          this.$alert('请选择未通过评审的信息！', '提示', {
            confirmButtonText: '确定'
          })
          return
        }
        if (this.selApproveArray.length != 0) {
          this.$alert('选中信息存在已评审信息，请只选择未评审的信息', '提示', {
            confirmButtonText: '确定'
          })
          return
        }
        var i = 1
        this.$confirm('您确定要通过评审该信息吗？', '提示', {
          confirmButtonText: '确定'
        }).then(() => {
          this.selNoApproveArray.forEach(element => {
            reviewBiddingMethod({ bidId: this.RefTypeData.bidId, reviewStatus: 'Y', sugarId: element.sugarId }).then(res => {
              if (res.success === '1' && i === this.selNoApproveArray.length) {
                this.$message({
                  type: 'success',
                  message: '评审成功'
                })
                this.openDialog = false
                this.RefCodeData = {}
                this.getCurrentTypeRow(this.RefTypeData)
              }
              i++
            })
          })
        })
      }
      //查询企业信息
      // this.openDialog = true
      // queryCompanyInfo({ fltUuid: this.RefCodeData.fltId}).then(res => {
      //   this.dialogForm = res.data.data
      // })
    },

    //评审通过
    reviewTure() {
      reviewBiddingMethod({ bidId: this.RefTypeData.bidId, reviewStatus: 'Y', sugarId: this.RefCodeData.sugarId }).then(res => {
        if (res.success === '1') {
          this.$message({
            type: 'success',
            message: '评审成功'
          })
          this.openDialog = false
          this.RefCodeData = {}
          this.getCurrentTypeRow(this.RefTypeData)
        }
      })
    },

    //取消评审
    reviewDel() {
      if (this.selApproveArray.length < 1) {
        if (Object.keys(this.currentCode).length == 0) {
          this.$alert('请选择需要取消评审的信息！', '提示', {
            confirmButtonText: '确定'
          })
          return
        }
        this.RefCodeData = Object.assign({}, this.currentCode)
        if (this.RefCodeData.reviewStatus == 'N') {
          this.$alert('请选择已通过评审的信息！', '提示', {
            confirmButtonText: '确定'
          })
          return
        }
        this.$confirm('您确定要取消评审该信息吗？', '提示', {
          confirmButtonText: '确定'
        }).then(() => {
          reviewBiddingMethod({ bidId: this.RefTypeData.bidId, reviewStatus: 'N', sugarId: this.RefCodeData.sugarId }).then(res => {
            if (res.success === '1') {
              this.$message({
                type: 'success',
                message: '取消评审成功'
              })
              this.openDialog = false
              this.RefCodeData = {}
              this.getCurrentTypeRow(this.RefTypeData)
            }
          })
        })
      } else {
        if (this.selApproveArray.length == 0) {
          this.$alert('请选择需要取消评审的信息！', '提示', {
            confirmButtonText: '确定'
          })
          return
        }
        if (this.selNoApproveArray.length != 0) {
          this.$alert('选中信息存在未评审信息，请只选择已评审的信息', '提示', {
            confirmButtonText: '确定'
          })
          return
        }
        var i = 1
        this.$confirm('您确定要取消评审该信息吗？', '提示', {
          confirmButtonText: '确定'
        }).then(() => {
          this.selApproveArray.forEach(element => {
            reviewBiddingMethod({ bidId: this.RefTypeData.bidId, reviewStatus: 'N', sugarId: element.sugarId }).then(res => {
              if (res.success === '1' && i === this.selApproveArray.length) {
                this.$message({
                  type: 'success',
                  message: '取消评审成功'
                })
                this.openDialog = false
                this.RefCodeData = {}
                this.getCurrentTypeRow(this.RefTypeData)
              }
              i++
            })
          })
        })
      }
    },

    getCurrentTypeRow(row) {
      this.currentCode = []
      this.selNoApproveArray = []
      this.selApproveArray = []
      this.currentPage = 1
      this.pageSize = 30
      this.pageTotal = 0
      this.currentType = row
      this.RefTypeData = Object.assign({}, row)
      quotaBiddingMethod({
        bidId: row.bidId
      }).then(res => {
        if (res.success == 1) {
          this.currentCodeList = res.data
        }
      })
    },

    //公告发布
    annouce() {
      if (Object.keys(this.RefTypeData).length == 0) {
        this.$alert('请选择需要发布公告的信息！', '提示', {
          confirmButtonText: '确定'
        })
        return
      }
      if (this.RefTypeData.bidBiddingstatus == 'N') {
        this.$alert('请选择已发布的信息', '提示', {
          confirmButtonText: '确定'
        })
        return
      }
      // queryAnnouncement({bidId:this.RefTypeData.bidId,
      // bidType:'Z'
      // }).then(res=>{
      //   if(res.success==='1'){
      //     if(res.data.length > 0){
      //       this.annouceData = res.data[0]
      //     }else{
      //       this.annouceData = {}
      //     }
      //     this.annoucetDialog = true
      //   }
      // })
      this.annoucetDialog = true
    },

    //确认发布公告
    annouceTrue() {
      this.$refs['annouceData'].validate(valid => {
        if (!valid) {
          // this.$message.error('必输项不能为空！')
          return false
        }
        addAnnouncement({
          baId: this.annouceData.baId,
          bidId: this.RefTypeData.bidId,
          bidTitle: this.annouceData.bidTitle,
          bidContent: this.annouceData.bidContent,
          bidType: 'Z'
        }).then(res => {
          if (res.success === '1') {
            this.annexDialog.data.id = res.data
            if (this.annexDialog.fileList.length) {
              this.$refs['annexUpload'].submit()
            }
            this.$message({
              type: 'success',
              message: '公告发布成功'
            })
            this.annoucetDialog = false
          }
        })
      })
    },

    //需求详情
    queryDemand(value) {
      this.operate = '需求详细信息'
      querytSignUpSugar({ sugarId: value.sugarId, bidId: this.RefTypeData.bidId }).then(res => {
        if (res.success === '1') {
          this.currentFltInfo = res.data[0]
          queryDemandLine({
            sugarId: value.sugarId
          }).then(res => {
            if (res.success == 1) {
              this.tranDialogInfoList = res.data
            }
          })
          this.showDialog = true
        } else {
          this.$message.error({
            message: '操作失败'
          })
        }
      })
    },
    //查看需求排名
    rankInfo(val) {
      queryBiddingInfoList({
        bidId: this.RefTypeData.bidId,
        sugarId: val.sugarId,
        biddingEnd: 'Y', //查询前三名推荐结果
        biddingStatus: 'Y' //已参与竞价的供应商
      }).then(res => {
        if (res.success == 1) {
          this.openDialog = true
          this.biddingResultList = res.data
          this.rankQuerry = false
        }
      })
    },

    // dialog 查看线路详细信息
    showTransportMethod(val) {
      queryDemandLine({
        sugarId: val.sugarId
      }).then(res => {
        if (res.success == 1) {
          this.tranDialogInfoList = res.data
        }
      })
      this.tranDialogInfoDialogVisible = true
    },

    // 获取当前选中行(多行)
    rowSelectionChange(val) {
      this.selNoApproveArray = []
      this.selApproveArray = []
      if (val.length > 0) {
        for (var i = 0; i < val.length; i++) {
          if (val[i].reviewStatus == 'Y') {
            this.selApproveArray.push(val[i])
          }
          if (val[i].reviewStatus == 'N') {
            this.selNoApproveArray.push(val[i])
          }
        }
      }
    },

    //关闭竞价结果推荐弹出框
    // guanbi(){
    //   this.openDialog2 = false
    //   this.currentCode = []
    // },
    //查看竞价结果
    queryBiddingButton() {
      console.log(this.currentCode,666666666666)
      if (Object.keys(this.currentCode).length == 0) {
        this.$alert('请选择需求信息！', '提示', {
          confirmButtonText: '确定'
        })
        return
      }
      queryBiddingInfoList({
        bidId: this.RefTypeData.bidId,
        sugarId: this.currentCode.sugarId,
        biddingEnd: 'Y', //查询前三名推荐结果
        biddingStatus: 'Y' //已参与竞价的供应商
      }).then(res => {
        if (res.success == 1) {
          this.openDialog2 = true
          this.biddingResultList2 = res.data
        }
      })
    },

    // 点击基础代码表格的一行，获取到当前行的信息
    getCurrentCodeRow(row) {
      this.codeentRow = '1'
      this.currentCode = row
    },

    handleSizeChangeA(val) {
      this.pageSize = val
      this.getRefCode()
    },
    handleCurrentChangeA(val) {
      this.currentPage = val
      this.getRefCode()
    },
    handleTypeDialogClose() {
      this.RefTypeDialogVisible = false
    },
    handleCodeDialogClose() {
      this.RefCodeDialogVisible = false
    },
    // restet 基础代码
    resetRefCode() {
      return (this.RefCodeData = {
        // RCT_UUID: '',
        // RV_DOMAIN: '',
        // RV_CMEANING: '',
        // RV_NAME: '',
        // RV_ISVALID: 'Y',
        rvDomain: '',
        rvTerId: '-1',
        rvLowValue: '',
        rvCmeaning: '',
        rvIsvalid: 'Y'
        // rvInsertuser:'',
        // rvLstupduser:'',
      })
    },
    doUploadFile() {
      this.annexDialog.show = false
    },
    addAnnex() {
      this.annexDialog.title = '添加附件'
      this.annexDialog.show = true
    },
    fileUploadFileCallBack(err, file, fileList) {
      this.$message.error(`${file.name}上传失败`)
    }
  }
}
</script>

<style lang="scss" scoped>
::v-deep .splitter-pane-resizer.horizontal {
  margin-top: -15px;
}

.app-container {
  overflow: hidden;
  background-color: #fff;
  position: relative;
  height: 100%;
}

.tree {
  padding-right: 20px;
  font-size: 1.4rem;
}

.right-detail {
  height: 100%;

  .top-type {
    width: 100%;
    height: 100%;

    table {
      max-width: 100%;
      font-size: 1.4rem;
    }
  }

  .bottom-code {
    width: 100%;
    height: 100%;
  }
}

.codeNumberCode {
  font-size: 1.4rem;
  font-weight: 500;
  line-height: 20px;
}

.basicInfoBox {
  border: 1px solid #cccccc;
  border-radius: 5px;
  padding-top: 25px;
  padding-bottom: 10px;
}
</style>
